<template>
<el-dialog
  title="题目审核"
  :visible.sync="checkDialog"
  width="30%"
  @close="closeDialog"
  @open="openDialog"
  >
  <div class='container'>
    <el-radio-group v-model="form.chkState">
      <el-radio  label="1">通过</el-radio>
      <el-radio  label="2">拒绝</el-radio>
    </el-radio-group>
    <el-input
      style="margin-top: 20px;"
      type="textarea"
      :rows="2"
      placeholder="请输入审核意见"
      v-model="form.chkRemarks">
    </el-input>
  </div>
  <span slot="footer" class="dialog-footer">
    <el-button @click="closeDialog">取 消</el-button>
    <el-button type="primary" @click="getChoiceCheck">确 定</el-button>
  </span>
</el-dialog>

</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'questionsCheck',
  props: {
    checkDialog: {
      type: Boolean,
      default: false
    },
    checkId: {
      type: Number
    }
  },
  data () {
    return {
      form: {
        id: '',
        chkState: '1',
        chkRemarks: ''
      }
    }
  },
  methods: {
    closeDialog () {
      this.$emit('close-checkdialog')
      this.form.chkState = '1'
      this.form.chkRemarks = ''
    },
    openDialog () {
      this.form.id = this.checkId
      // console.log(this.checkId)
      // console.log(this.form)
    },
    async getChoiceCheck () {
      if (this.form.chkRemarks.trim() === '') {
        this.$message.warning('请输入审核意见')
        return
      }
      // ...this.form,
      //   chkState: Number(this.form.chkState)
      // console.log(this.form, 'this.form')
      await choiceCheck({
        ...this.form,
        chkState: Number(this.form.chkState)
      })
      this.$message.success('操作成功')
      this.closeDialog()
      this.$emit('uplod-list')
      // console.log(res)
    }
  }
}
</script>

<style scoped lang='scss'>

</style>
